import _ from "lodash"; //导入loadsh插件



//数据格式化为echarts需要到数据-后台管理图表
export function dataformat(value, flage = false, home = false) {
  if (home.type != 3) {
    home = false
  }
  var filediv = /(<\/?div.*?>)/gi;
  let filehtml = /<\/?[^>]*>/g;
  var filnbsp = /&nbsp;/g;
  var filkh = />/g;
  var spanreg2 = /(<\/?span.*?>)/gi;
  let arr = _.cloneDeep(value);
  arr.content.forEach((item) => {
    item.forEach((datares) => {
      if (datares.type == "1") {
        if (datares.value.replace(filehtml, '').replace(filnbsp, '').replace(/ /ig, '').replace(filkh, '') == '') {
          datares.value = ''
        }
        datares.value = datares.value.replace(spanreg2, '')
        // if (flage){
        //   if(datares.value.includes('<span style="display:none;"></span>')){
        //     datares.value =datares.value.replace('<span style="display:none;"></span>','<br>')
        //   }
        //   datares.value = datares.value.replace(filediv,'')
        // }
        let fontwebkey = getRandomCodes(25);
        datares.fontwebkey = fontwebkey
        Object.keys(datares.grep).forEach(grepitem => {
          var grepwebid = getRandomCodes(25)
          datares.grep[grepitem].webid = grepwebid
          if (flage) {//编辑页面
            if (datares.grep[grepitem].value) {
              datares.value = datares.value.replace(grepitem, `<span id="${grepwebid}" style="background:rgb(255,253,56);">${datares.grep[grepitem].value}</span>`)
            } else {
              datares.value = datares.value.replace(grepitem, `<span id="${grepwebid}" style="background:rgb(255,253,56);">${datares.grep[grepitem].value}请输入总结性话语</span>`)
            }
          } else {
            datares.value = datares.value.replace(grepitem, `<span id="${grepwebid}" >${datares.grep[grepitem].value}</span>`)
          }
        })
      }
      if (datares.type == "2") {
        datares.webkeyss = getRandomCodes(20);
        if (datares.value.chartType == 14 || 
          datares.value.chartType == 10 || 
          datares.value.chartType == 15|| 
          datares.value.chartType == 17|| 
          datares.value.chartType == 18|| 
          datares.value.chartType == 19|| 
          datares.value.chartType == 20|| 
          datares.value.chartType == 21) return false;
        datares.value.chartTitleid = getRandomCodes(19);
        datares.value.chartSourceid = getRandomCodes(19);
        datares.webkey = getRandomCodes(19);
        datares.option = {
          legend: {
            data: [],
            top: "20",
            align: 'left',
            itemGap: 15,
            padding: [6, 0, 0, 4],
            itemHeight: 10,
            textStyle: {
              fontSize: "12",
              fontFamily: "楷体",
              color: '#000',
            },

          },
          title: {
            //图表名称
            text: "",
            textStyle: {
              fontSize: 8,
              color: "#000",
              fontWeight: 500,
              fontFamily: "楷体",
            },
          },
          toolbox: {
            feature: {
              magicType: {
                type: ["stack"],
                show: false,
              },
              dataView: {
                show: false,
              },
            },
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'cross',
              label: {
                backgroundColor: '#6a7985',
              },
            },
            textStyle: {
              align: 'left',
              fontFamily: "楷体",
            }
          },
          //   plotOptions: {
          //     series: {
          //         connectNulls: true //连接数据为null的前后点
          //     }
          // },
          xAxis: {
            type: '',
            data: [], //x列表,
            name: "", //x轴名称
            axisLine: {
              //x轴
              show: true,
              lineStyle: {
                color: '#E0E0E0'//刻度颜色
              }
            },
            axisLabel: {
              interval: 0,
              fontSize: "10", //y轴刻度字体样式
              color: '#000',
              fontWeight: "400",
              fontFamily: "楷体",
              width: datares.value.xshowType == 1 ? 70 : 50,
              height: 100,
              overflow: 'break'
            },
            axisTick: {
              show: false,
              lineStyle: {
                color: '#E0E0E0'//刻度颜色
              },
              interval: 'auto',
              alignWithLabel: true,
            },
            splitLine: { show: false },
            splitArea: { show: false },
          },
          yAxis:
            [{
              name: "2",
              splitNumber: 5,
              minInterval: 1,
              // interval:1,
              nameTextStyle: {
                align: "right",
                fontSize: 14,
                fontFamily: "楷体",
                lineHeight: 70,
                color: '#000'
              },
              nameLocation: 'center',
              axisTick: {
                show: true,
              },
              axisLine: {
                //y轴是否显示
                show: true,
                lineStyle: {
                  color: '#000'
                }
              },
              axisLabel: {
                interval: 0,
                fontSize: "10", //y轴刻度字体样式
                color: '#000',
                fontWeight: "400",
              },
              splitLine: {
                show: false,//y轴图表的线
              },
            },
            ],
          grid: {//图表样式
            // top: "top", //距上边距
            left: "10%", //距离左边距
            right: "4%", //距离右边距
            bottom: "4%", //距离下边距
            containLabel: true,
          },
          series: [],
        };

        datares.option.title = {
          text: datares.value.chartName,
          textStyle: {
            fontSize: 16,
            color: "#000",
            fontWeight: 400,
            fontFamily: "楷体",
          },
        };
        datares.option.xAxis.axisLabel.rotate = datares.value.xshowType == 1 ? '90' : 0;
        //
        if (datares.value.skipType != 3 || datares.value.skipType != 2 || datares.value.skipType != -1 || datares.value.chartType == "13") {
          // datares.value.x.values.forEach((itemx) => {
          //   if (itemx.includes('-')) {
          datares.option.xAxis.axisLabel.formatter = (v) => {
            if (datares.value.x.values.length <= 21) {
              return v
            }
            if (v.includes('-')) {
              if (v.replace(/-/, '').includes('-01')) {
                return v
              } else {
                return ''
              }
            } else {
              return v
            }
          }
          //   }
          // })
        }
        //3：日频数据每15天一展示
        if (datares.value.skipType == 3) {
          datares.option.xAxis.axisTick.show = false
          datares.option.xAxis.axisLabel.formatter = (v, i) => {
            if (datares.value.x.values.length <= 21) {
              return v
            }
            if (datares.value.x.values > 21 && datares.value.x.values < 84) {
              if (i % 3 == 0) {
                return v
              } else {
                return ''
              }
              // str.substring(0,str.length-3)
            }
            if (i % 15 == 0) {
              return v
            } else {
              return ''
            }
          }
        }
        //2月频数据间隔三个月展示（也就是1/5/9月）
        if (datares.value.skipType == 2) {

          datares.option.xAxis.axisLabel.formatter = (v, i) => {
            if (datares.value.x.values.length <= 22) {
              return v
            }
            if (datares.value.x.values.length > 84) {
              if (v.includes('-')) {
                if (v.includes('-01')) {
                  return v
                } else {
                  return ''
                }
              } else {
                return v
              }
            }
            if (i % 4 == 0) {
              return v
            } else {
              return ''
            }
          }
        }


        //显示年份加月份01-01
        // if (datares.value.xshowType == 2) {
        //   datares.value.x.values.forEach((itemx) => {
        //     if (itemx.includes('-')) {
        //       datares.option.xAxis.axisLabel.formatter = (v) => {
        //         if (v.includes('-01')) {
        //           return v
        //         } else {
        //           return ''
        //         }
        //       }
        //     }
        //   })
        // }

        datares.option.xAxis.data = datares.value.x.values;

        let yarr = [];
        let xarr = [];
        let maxarr = []
        let maxarr6 = []
        let minarr6 = []
        // let flage = datares.value.y.some((ydata) => {
        //   return ydata.showNew
        // })
        // if(flage){
        //   datares.option.grid.right = '10%'
        // }else{
        //   datares.option.grid.right = '1%'
        // }
        datares.value.y.forEach((ydata, index) => {
          ydata.showNew ? ydata.showNew = true : ydata.showNew = false
          let someflage = ydata.values.some(someitem => {
            return someitem
          })
          yarr.push({
            name: ydata.cutlineName?ydata.cutlineName:'-',
            type:
              datares.value.chartType == "1" || datares.value.chartType == "5"
                ? "bar"
                : datares.value.chartType == "2" || datares.value.chartType == "4" || datares.value.chartType == "8"
                  ? "line"
                  : datares.value.chartType == "3" || datares.value.chartType == "6" || datares.value.chartType == "7" || datares.value.chartType == "9" || datares.value.chartType == "12" || datares.value.chartType == "11" || datares.value.chartType == "13"||datares.value.chartType == "16"||datares.value.chartType == "23"
                    ? ydata.stack == "2"
                      ? "line"
                      : ydata.stack == "0"
                        ? "line"
                        : ydata.stack == "1"||ydata.stack == "8"||ydata.stack == "9"
                          ? "bar"
                          : ydata.stack == -1
                            ? 'line'
                            : "line"
                    : "line",
            connectNulls: true,
            barMaxWidth:9,
            barMinWidth: 1,
            smooth: datares.value.chartType == "12" ? 0.6 : 0,
            stack: datares.value.chartType == "2" || datares.value.chartType == "4" || datares.value.chartType == "8"
              ? ""
              : datares.value.chartType == "1" || datares.value.chartType == "5" ? "one"
                : datares.value.chartType == "3" || datares.value.chartType == "6" || datares.value.chartType == "7" || datares.value.chartType == "9" || datares.value.chartType == "12" || datares.value.chartType == "11" || datares.value.chartType == "13"||datares.value.chartType == "16"||datares.value.chartType == "23"
                  ? ydata.stack == "0"
                    ? ""
                    : ydata.stack == "1"
                      ? "one"
                      : ydata.stack ==8?'type_8':ydata.stack==9?'type_9':''
                  : "",
            areaStyle: {
              opacity: ydata.stack == 2 ? 1 : 0,
              color: ydata.color,
            },
            symbol: 'circle',
            showSymbol: datares.value.chartType == 6 || datares.value.chartType == "7" || datares.value.chartType == "11"
              ? true
              : ydata.values.length > 1
                ? false
                : true,//是否显示小圆点
            endLabel: {//最后一个数
              show: ydata.showNew ? true : datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5?true:false,
              color: '#000',
              fontSize: 12,
              offset: [0, 0],
              formatter: function (params) {
                if (datares.value.chartType == "12") {
                  return params ? (params.value * 10).toFixed(0) / 10 : ''
                } else {
                  return params.value == 0 ? 0 : params.value;
                }
              }
            },

            label: {
              show: home && home.type == 3 ? ydata.isNew ? true :false
                : datares.value.chartType == 6 || datares.value.chartType == 7 || datares.value.chartType == 11
                  ? true
                  : false,
              position: index % 2 == 0 ? 'top' : 'bottom',
              fontSize: 12,
              formatter: (params) => {
                if (home && home.type) {
                  if (ydata.stack == "0") {
                    if (params.dataIndex % 2) {
                      return ''
                    } else {
                      return params.value
                    }
                  }
                  if (ydata.stack == "1") {
                    if (params.dataIndex % 2 == 0) {
                      return ''
                    } else {
                      return params.value
                    }
                  }
                } else {
                  return params.value
                }
              },
            },
            labelLayout: {
              moveOverlap: 'shiftY'
            },
            markPoint: {

              label: {
                color: "#000",
                fontSize: 12,
                position: index % 2 == 0 ? 'top' : 'bottom',
                offset: [20, 10],
              },
              symbolSize: 0,
              data: datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 || datares.value.chartType == 5
              ?datares.value.chartType == 5&&ydata.stack == 0
              ?[{ name: '最新值', value: ydata.values[ydata.values.length - 1], xAxis: 'max', yAxis: ydata.values[ydata.values.length - 1] },]
              :ydata.stack == 1
              ?[{ name: '最新值', value: ydata.values[ydata.values.length - 1], xAxis: 'max', yAxis: ydata.values[ydata.values.length - 1] },]
              :ydata.showNew&&ydata.stack == 1
              ? [{ name: '最新值', value: ydata.values[ydata.values.length - 1], xAxis: 'max', yAxis: ydata.values[ydata.values.length - 1] },]
              : [] :[]
            },
            itemStyle: ydata.dott?{
              color:'rgba(0,0,0,0)',
              borderColor:ydata.color,
              borderType:'dashed'
            }:{
              normal: {
                color: ydata.color,
              },
            },
            lineStyle: {
              width: 1.5,
              type: ydata.stack == -1 ? 'dashed' : datares.value.chartType == "12"?'':ydata.lineType == 0 ? 'dashed' : ''
            },
            cutlineShows: ydata.cutlineShow == 1 ? true : false,
            yAxisIndex: ydata.pos ? ydata.pos == 'l' ? 0 : ydata.pos == 'r' ? 1 : '' : '0',
            data: someflage ? ydata.values : [...ydata.values, 0],
          });
          if(ydata.showNew){
            datares.option.grid.right='14%'
          }
          if (datares.value.chartType == "8") {
            let lowListarr = []
            datares.value.lowList.forEach(lowListitem => {
              lowListarr.push(
                [{
                  name: '套利',
                  label: {
                    position: "insideTopLeft",
                    color: '#000'
                  },

                  itemStyle: {
                    color: 'rgba(0,0,0,0)',
                    borderColor: '#000',
                    borderWidth: 1,
                  }, //颜色设置
                  xAxis: lowListitem.startx,
                  yAxis: lowListitem.starty
                }, {
                  xAxis: lowListitem.endx,
                  yAxis: lowListitem.endy
                }]
              )
            })
            yarr.filter(yarritem => {
              return yarritem.data.length > 1
            })[0].markArea = {
              data: lowListarr,
              silent: true,
            }
          }
          maxarr.push(...ydata.values)
          if (datares.value.rightUnit && datares.value.leftUnit) {
           
            if (ydata.pos == 'l') {
              maxarr6.push(...ydata.values)
            }
            if (ydata.pos == 'r') {
              minarr6.push(...ydata.values)
            }
          }
          
          if (ydata.cutlineShow == "1") {

            // 首页金融数据流动性图表单独处理
            let xarroption = [{
              name: ydata.cutlineName?ydata.cutlineName:'-',
              textStyle: {
                color: '#000',
              }
            }]
            xarr.push(...xarroption);
          }
        });

        let maxnum = Math.max(...maxarr)
        let minnum = Math.min(...maxarr)
        datares.option.yAxis = [
          {
            name: datares.value.unit,
            splitNumber: 5,
            minInterval: 1,
            nameTextStyle: {
              align: "right",
              fontSize: 14,
              fontFamily: "楷体",
              lineHeight: 10,
              color: '#4D4F5C'
            },
            nameLocation: 'center',
            axisTick: {
              show: true,
            },
            axisLine: {
              //y轴是否显示
              show: true,
              lineStyle: {
                color: '#E0E0E0'
              }
            },
            axisLabel: {
              interval: 0,
              fontSize: "10", //y轴刻度字体样式
              color: '#4D4F5C',
              fontWeight: "400",
            },
            splitLine: {
              show: false,//y轴图表的线
            },
          },
        ]
        // datares.value.y.some((ydataevery)=>{
        //   return ydataevery.showNew
        // })?datares.option.grid.right='12%':datares.option.grid.right='0%'
        //根据y轴刻度最大值改变单位距离刻度线距离

        if (maxnum > 500) {
          datares.option.yAxis[0].nameTextStyle.lineHeight = 70
          datares.option.grid.left = '8%'
        }
        if (maxnum <= 500) {
          datares.option.yAxis[0].nameTextStyle.lineHeight = 20
          datares.option.grid.left = '8%'
        }
        if (minnum < -500) {
          datares.option.yAxis[0].nameTextStyle.lineHeight = 70
          datares.option.grid.left = '8%'
        }
        if (minnum <= 100 && minnum > 0) {
          let numminnum = parseInt(minnum)
          if (datares.value.chartType != "12") {
            datares.option.yAxis[0].min = `${numminnum -= 1}`
          }
        }
        //  if(minnum==0){
        //   datares.option.yAxis[0].min = '-5'
        //  }

        datares.option.series = yarr;
        datares.option.legend.data = xarr;
        datares.option.yAxis[0].name = datares.value.unit;
        if (datares.value.leftUnit && datares.value.rightUnit) {
          let maxnum6 = Math.max(...maxarr6)//l
          let minnum6 = Math.max(...minarr6)//r
          if (minnum6 < 0) {
            minnum6 = 2
          }
          // datares.option.xAxis.axisLine.show = false
          // datares.option.xAxis.axisTick.show = false
          if (datares.value.chartType == "6") {
            //l
            let type6min = Math.min(...maxarr6)
            let type6max = Math.max(...maxarr6)
            let roundtype6max = Math.round(type6max += 0.5)
            let roundtype6min = Math.round(type6min -= 1.5)
            //r
            let rtype6min = Math.min(...minarr6)
            let rtype6max = Math.max(...minarr6)
            let rroundtype6min = Math.round(rtype6min)
            let rmax = 0
            rtype6max < 10 ? rmax = 50 : rtype6max < 50 && rtype6max > 10 ? rmax = 200 : rmax = rtype6max
            let typer6 = 0
            rroundtype6min < 0 && rroundtype6min > -10 ? typer6 = -10 : typer6 = rroundtype6min
            // var yshownews = datares.value.y.some(y_some_item=>{
            //   return y_some_item.showNew
            // })
            // if(datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5){
            //   yshownews=true
            //  }
             ////////
            datares.option.yAxis = [
              {
                name: datares.value.unit,
                splitNumber: 5,
                min: roundtype6min,
                max: roundtype6max,
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 30,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              },

              {
                // offset:yshownews?40:0,
                name: datares.value.unit,
                min: typer6,
                max: rmax,
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 20,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              }
            ]
            datares.option.grid.left = '10%'
            datares.option.grid.right = '10%'
          }
          if (datares.value.chartType == "7") {
            //l
            let type6min = Math.min(...maxarr6)
            let type6max = Math.max(...maxarr6)
            let roundtype6max = Math.round(type6max)
            let roundtype6min = Math.round(type6min -= 0.5)
            //r
            let rtype6min = Math.min(...minarr6)
            let rtype6max = Math.max(...minarr6)
            let rroundtype6max = Math.round(rtype6max += 0.5)
            let rroundtype6min = Math.round(rtype6min)
            let rmax = 0
            rtype6max < 10 ? rmax = 20 : rtype6max < 50 && rtype6max > 10 ? rmax = 200 : rmax = rtype6max
            var yshownewss = datares.value.y.some(y_some_item=>{
              return y_some_item.showNew
            })
            if(datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5){
              yshownewss=true
             }
            datares.option.yAxis = [
              {
                name: datares.value.unit,
                // splitNumber: 5,
                min: roundtype6min,
                max: roundtype6max += 0.5,
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 30,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  // interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                  formatter: function (value, index) {
                    if (`${value}`.length == 1) {
                      if (value == 0) return value
                      return `${value}.0`
                    } else {
                      return value
                    }
                  }
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              },

              {
                name: datares.value.unit,
                splitNumber: 5,
                // offset:yshownewss?40:0,
                minInterval: 1,
                min: rroundtype6min,
                max: rmax,
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 30,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              }
            ]
            datares.option.grid.right = '8%'
            datares.option.grid.left = '10%'
          }
          if (datares.value.chartType == "9"|| datares.value.chartType == 16|| datares.value.chartType == 12|| datares.value.chartType == 23) {
            // var yshownew = datares.value.y.some(y_some_item=>{
            //   return y_some_item.showNew
            // })
            // if(datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5){
            //   yshownew=true
            //  }
            datares.option.yAxis = [
              {
                name: "",
                splitNumber: 5,
                minInterval: 1,
                // interval:1,
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 10,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              },
              {
                name: "",
                splitNumber: 5,
                minInterval: 1,
                // offset:yshownew?40:0,
                // interval:1,
                // max:datares.value.chartType==6?215:'dataMax',
                nameTextStyle: {
                  align: "right",
                  fontSize: 14,
                  fontFamily: "楷体",
                  lineHeight: 20,
                  color: '#4D4F5C'
                },
                nameLocation: 'center',
                axisTick: {
                  show: true,
                },
                axisLine: {
                  //y轴是否显示
                  show: true,
                  lineStyle: {
                    color: '#E0E0E0'
                  }
                },
                axisLabel: {
                  interval: 0,
                  fontSize: "10", //y轴刻度字体样式
                  color: '#4D4F5C',
                  fontWeight: "400",
                },
                splitLine: {
                  show: false,//y轴图表的线
                },
              }
            ]
            // datares.option.grid.right = '14%'
            // home?datares.option.grid.right = '10%':''
          }
          
          datares.option.yAxis[0].name = datares.value.leftUnit
          datares.option.yAxis[1].name = datares.value.rightUnit
          let maxnumtype6 = Math.max(...maxarr6)//l
          let minnumtype6 = Math.min(...maxarr6)//l
          let maxnumtype6s = Math.max(...minarr6)//r
          let minnumtype6s = Math.max(...minarr6)//r
          // let minnum = Math.min(...maxarr)
          if (maxnumtype6 > 500) {
            datares.option.yAxis[0].nameTextStyle.lineHeight = 70
          }
          if (maxnumtype6 <= 500 && maxnumtype6 > 0) {
            datares.option.yAxis[0].nameTextStyle.lineHeight = 20
          }
          if (minnumtype6 < -500) {
            datares.option.yAxis[0].nameTextStyle.lineHeight = 70
          }
          if (maxnumtype6s > 500) {
            datares.option.yAxis[1].nameTextStyle.lineHeight = 70
          }
          if (maxnumtype6s <= 500 && maxnumtype6s > 0) {
            datares.option.yAxis[1].nameTextStyle.lineHeight = 20
          }
          if (minnumtype6s < -500) {
            datares.option.yAxis[1].nameTextStyle.lineHeight = 70
          }
        }
        if (datares.value.chartType == "8") {
          let maxdata = parseInt(maxnum)
          let mindata = Math.round(minnum)
          datares.option.yAxis = [
            {
              name: datares.value.unit,
              splitNumber: 5,
              minInterval: 1,
              // interval:1,
              min: mindata -= 1,
              max: maxdata += 1,
              nameTextStyle: {
                align: "right",
                fontSize: 14,
                fontFamily: "楷体",
                lineHeight: 10,
                color: '#4D4F5C'
              },
              nameLocation: 'center',
              axisTick: {
                show: true,
              },
              axisLine: {
                //y轴是否显示
                show: true,
                lineStyle: {
                  color: '#E0E0E0'
                }
              },
              axisLabel: {
                interval: 0,
                fontSize: "10", //y轴刻度字体样式
                color: '#4D4F5C',
                fontWeight: "400",
              },
              splitLine: {
                show: false,//y轴图表的线
              },
            },
          ]
          datares.option.grid.right = '8%'
        }
     if(datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5){
      if (datares.value.leftUnit && datares.value.rightUnit){
        // datares.option.grid.right = '1%'
      }else{
        datares.option.grid.right = '14%'
      }
     }
     var yshownew = datares.value.y.some(y_some_item=>{
      return y_some_item.showNew
    })
    if(datares.value.chartType == 1 || datares.value.chartType == 3 ||datares.value.chartType == 9||datares.value.chartType == 16 ||datares.value.chartType == 5){
      yshownew=true
     }
     if(yshownew&&datares.value.leftUnit && datares.value.rightUnit){
      let xnum = parseInt(datares.value.x.values.length*0.15)
      for(let x_i = 0; x_i<xnum; x_i++){
        datares.value.x.values.push('')
      }
      datares.option.xAxis.data = datares.value.x.values;
     }
      }
    });
  });
  return arr;
}




export function getRandomCode(length) {
    if (length > 0) {
      var data = [
        "0",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z",
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z",
      ];
      var nums = "";
      for (var i = 0; i < length; i++) {
        var r = parseInt(Math.random() * 61);
        nums += data[r];
      }
      return nums;
    } else {
      return false;
    }
  }

function getRandomCodes(length) {
    if (length > 0) {
      var data = [
        "0",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z",
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z",
      ];
      var nums = "";
      for (var i = 0; i < length; i++) {
        var r = parseInt(Math.random() * 61);
        nums += data[r];
      }
      return nums;
    } else {
      return false;
    }
  }